package com.tyl.stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/*
* 链式编程
* 题目：
* 1、id必须是偶数
* 2、年龄必须大于15
* 3、用户转为大写
* 4、倒序排序
* 5、只输出一个用户
* */
public class Test {
    public static void main(String[] args) {
        User user1 = new User(1,"a",15);
        User user2 = new User(2,"b",16);
        User user3 = new User(3,"c",17);
        User user4 = new User(4,"d",18);
        User user5 = new User(5,"e",19);
        List<User> list = Arrays.asList(user1, user2, user3, user4, user5);
        //System.out.println(list);
        //计算交给Strema流计算
        list.stream().filter(user -> {return user.getId()%2==0;})
                .filter(user -> {return user.getAge()>15;})
                .map(user -> {return user.getName().toUpperCase();})
                .sorted((u1,u2)->{return u2.compareTo(u1);})
                .limit(1)
                .forEach(System.out::println);

    }
}
